﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/CSS/xiaoliu.css" rel="stylesheet" />
    <link href="~/CSS/style.css" rel="stylesheet" />
    <script src="~/JS/jquery-3.1.1.min.js"></script>
    <script src="~/JS/xiaoliu.js"></script>
    <title>登录界面-海南省旅游和文化广电体育厅住宿业管理系统</title>
    <style>
        body {
            width: 100%;
            margin: 0;
            padding: 0;
            border: 0;
            background-color: #FFFFFF;
            background-image: url(../../Image/login_bg.jpg);
            background-position: center 0;
        }
    </style>
</head>
<body>
    <div class="loginbox">
        <div class="kong"></div>
        <div class="login">
            <div class="login-left">
                <div class="login_kong"></div>
                <div class="login_txt">
                    欢迎来到<img src="~/image/jiantou.png" width="22" />
                </div>
                <div class="login_txt">
                    海南省旅游和文化广电体育厅<br />
                    住宿业管理系统
                </div>
            </div>
            <div class="login-form">
                <div class="loginname">用户登录</div>
                <div class="formbox">
                    <input id="user-name" type="text" required="required" placeholder="请输入手机号码" class="txtsize tel" value="13807538794" />
                    <div class="yzmbox">
                        <div class="yamleft">
                            <input id="imgyzm" type="text" required="required" placeholder="请输入验证码" class=" yzm01" value="1111" />
                        </div>
                        <div class="yamright">
                            <img id="imgyzm_url" src="/login/getyanzhengma" onclick="getyanzhengma();" />
                        </div>
                    </div>
                    <div id="divsendduanxin" class="pass" onclick="sendduanxin();" style="cursor:pointer;">发送手机验证码</div>
                    <input id="dxyzm" type="text" placeholder="请输入手机验证码" class="yzm02" value="1111" />
                    <div class="qyzc" style="cursor:pointer;" onclick="to_url('/login/zhuceview');">企业注册</div>
                    <button id="login" class="but">登录</button>
                    <label id="lb_errmg" class="ft-red" style="display:none;">登录失败</label>
                </div>
            </div>
        </div>
    </div>
    <div class="navbar-fixed-bottom" style="text-align: center; color: #fff;">© 版权所有 2020-2021 </div>



    <script type="text/javascript">
        var intervalindex = -1;
        $(function () {
            $("#login").click(function () {
                showerr(false);
                if ($("#user-name").val() === "") {
                    showerr(true, "请输入电话！");
                    return false;
                }
                if ($("#imgyzm").val() === "") {
                    showerr(true, "请输入图片验证码！");
                    return false;
                }
                $.post("/Login/LoginP", { name: $("#user-name").val(), imgyzm: $("#imgyzm").val(),dxyzm:$("#dxyzm").val() },
                    function (res) {
                        if (!$.isEmptyObject(res)) {
                            if (res.code <= 0) {
                                showerr(true, res.msg);
                            }
                            else {
                                location.href = res.data;
                            }
                        }
                        else {
                            alert("网络异常！");
                        }
                    }
                );
            });
            //账号输入框焦点
            $("#user-name").focus();
        });

        document.onkeydown = function (e) {
            if (e.keyCode == 13) {
                if ($("#user-name").val() == "") {
                    $("#user-name").focus();
                    return false;
                }
                if ($("#imgyzm").val() == "") {
                    $("#imgyzm").focus();
                    return false;
                }
                $("#login").click();
            }
        }

        function getyanzhengma() {
            $("#imgyzm_url").attr("src", "/login/getyanzhengma?v=" + Math.random());
        }
        function showerr(show, msg) {
            if (show) {
                $("#lb_errmg").html(msg);
                $("#lb_errmg").show();
            }
            else {
                $("#lb_errmg").hide();
            }            
        }
        function sendduanxin() {
            $.post("/login/sendduanxin", { name: $("#user-name").val(), imgyzm: $("#imgyzm").val()}, function (res) {
                showerr(true, res.msg);
                if (res.code > 0) {
                    var secondleft = 59;
                    intervalindex = setInterval(function () {
                        if (secondleft > 0) {
                            secondleft--;
                            $("#divsendduanxin").html("重试(" + secondleft + ")");
                        }
                        else {
                            clearInterval(intervalindex);
                            $("#divsendduanxin").html("发送手机验证码");
                        }
                    }, 1000)

                }
            })
        }



    </script>

</body>
</html>
